#include <gtkmm/window.h>

#include "gamescreen.h"

//add menubar procedure++++++++++++++++++++++++++
//===============================================
//gameContainer++++++++++++++++++++++++++++++++++
//constructors----------
gameContainer::gameContainer(){
    mapdisp.connectParent(this);
    infdisp.connectParent(this);
    mapdisp.set_visible(true);
    infdisp.set_visible(true);

    infdisp.set_homogeneous(false);

    add(infdisp);
    add(mapdisp);
    mapdisp.requestCursorMove(&infdisp);
}
gameContainer::~gameContainer(){
}
//cursor----------------
cursorServer*  gameContainer::getCursor(){
    return &mapdisp;
}
//===============================================
//infoScreen+++++++++++++++++++++++++++++++++++++
//constructors----------
infoScreen::infoScreen(){
    //set up the infoscr settings
    set_size_request(minInfoWid, minInfoHgt);
    set_homogeneous(false);

    //set up the drawing area widget
    iconSpace.set_size_request(minIconWid, minIconHgt);
}
infoScreen::~infoScreen(){

}
void infoScreen::connectParent(gameContainer* par){
    parent = par;
}
//dispaly function------
void infoScreen::displayInfo(string str){
    stringstream strm(str);
    strm >> icnId;
    string temp;
    strm >> temp;
//    resName.set_label(temp);
    strm.clear();
    strm << "(" << cx << ", " << cy << ")" << endl;
    strm >> temp;
  //  coords.set_label(temp);
    redraw();
}
void infoScreen::redraw(){
    int center[2];
    center[0] = iconSpace.get_width() / 2;
    center[1] = iconSpace.get_height() / 2;
    iconTable::draw(icnId, iconSpace.get_window()->create_cairo_context(), center);
}
//siganl handlers-------
void infoScreen::signal_curs_enter(int x, int y){
    cx = x;
    cy = y;
}
void infoScreen::signal_curs_move(int x, int y){
    cx = x;
    cy = y;
}
//===============================================
//mapScreen++++++++++++++++++++++++++++++++++++++
//constructor-----------
mapScreen::mapScreen(){
}
mapScreen::~mapScreen(){
}
void mapScreen::connectParent(gameContainer* par){
    parent = par;
}
//events----------------
bool mapScreen::on_expose_event(GdkEventExpose* event){
    draw();
}
bool mapScreen::on_key_press_event(GdkEventKey* key){
    
}
bool mapScreen::keypress(GdkEventKey* key){
    
}
//drawing---------------
void mapScreen::draw(){
    Glib::RefPtr<Gdk::Window> window = get_window();
    if(window != NULL){
        Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
        cr->save();
        cr->set_source_rgb(0,0,0);
        cr->paint();
        cr->restore();
    }
}
void mapScreen::scroll(){

}
void mapScreen::scroll(direction dir, int dist){

}
//math------------------
void mapScreen::recalculateBounds(){
    
}
//===============================================